智力测试
题目 智力测试
思路分析
代码实现
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int N=1e4+10;
ll s[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n;cin>>n;
for(int i=1;i<=N;i++) {
s[i]=s[i-1]+(i*(i+1)/2);
if(s[i]>n){
cout<<i-1<<endl;
return 0;
}
}
return 0;
}
同类题型
视频讲解
⬅️ 航班时间 🏠 00-刷题理模型 ➡️ 暴力 枚举 模拟 问题
💬 评论